using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableEquipRefineDao:DaoBase<TableEquipRefine>
    {
        public override void AddPrimaryIndex(TableEquipRefine model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableEquipRefine.txt";
        }

        protected override TableEquipRefine ParseRowData(string[] rowData)
        {
            TableEquipRefine data = new TableEquipRefine();
			data.id = rowData [0];

            if (string.IsNullOrEmpty(rowData[1]))
            {
                data.type = 0;
            }
            else
            {
                data.type = int.Parse(rowData[1]);
            }

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.quality = 0;
            }
            else
            {
                data.quality = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.attGrow = 0;
            }
            else
            {
                data.attGrow = double.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.criGrow = 0;
            }
            else
            {
                data.criGrow = double.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.mdefGrow = 0;
            }
            else
            {
                data.mdefGrow = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.perevadeGrow = 0;
            }
            else
            {
                data.perevadeGrow = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.hpGrow = 0;
            }
            else
            {
                data.hpGrow = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.perhitGrow = 0;
            }
            else
            {
                data.perhitGrow = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.pdefGrow = 0;
            }
            else
            {
                data.pdefGrow = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.anticriGrow = 0;
            }
            else
            {
                data.anticriGrow = double.Parse(rowData[10]);
            }

            return data;
        }



        public override void AddTwoIndex(TableEquipRefine model)
        {
            string key = GetUnionKey(model.type.ToString(),model.quality.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TableEquipRefine>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
